
#import <Foundation/Foundation.h>


@interface NSString (Extensions)

/**
 * return yes if the str is nil or empty or contains only whitespace.
 */
+ (BOOL)isBlank:(NSString *)str;

/**
 * return no if the str is nil or empty or contains only whitespace.
 */
+ (BOOL)isNotBlank:(NSString *)str;

/**
 * return yes if the str is numeric ,otherwise no.
 */
+ (BOOL)isNumeric:(NSString *)str;

/**
 * return string by base64.
 */
+ (NSString *)base64StringFromData:(NSData *)data length:(NSUInteger)length;

- (BOOL)isContain:(NSString*)asubstr;

- (BOOL)isPhoneNumber;

- (BOOL)isNumber;

- (BOOL)isNonnegativeNumber;

- (BOOL)isMore4Decimal;

- (BOOL)isEmail;

- (BOOL)isPhoneNumberOrEmail;

- (BOOL)isURL;

- (void)detectAllEmailWithBlock:(void (^)(NSString *email, NSRange range, volatile BOOL *const stop))emailBlock;

- (void)detectAllPhoneNumberWithBlock:(void (^)(NSString *phone, NSRange range, volatile BOOL *const stop))phoneBlock;

- (void)detectAllURLWithBlock:(void (^)(NSString *URL, NSRange range, volatile BOOL *const stop))URLBlock;

/**
 * Determines if the string contains only whitespace and newlines.
 */
- (BOOL)isWhitespaceAndNewlines;

/**
 * Determines if the string is empty or contains only whitespace.
 */
- (BOOL)isEmptyOrWhitespace;

/**
 * Calculate the md5 hash of this string using CC_MD5.
 *
 * @return md5 hash of this string
 */
- (NSString *)md5Hash;

- (NSString *)trim;
- (NSString *)trimBegin:(NSString *)strBegin;
- (NSString *)trimEnd:(NSString *)strEnd;
- (NSString *)trim:(NSString *)strTrim;

- (NSString *)replaceCRWithNewLine;

- (NSString *)replaceOldString:(NSString *)strOld WithNewString:(NSString *)strNew;

- (NSString *)UTIType;

- (NSString *)MIMETypeForPathExtension;

@end
